/*
 * @file     g_powerkey.h
 * @brief    source file for setting powerkey
 *
 * Change Logs:
 * Date           Author             Version        Notes
 * 2021-05-25     xubo               V1.0.0         the first version
 */

#ifndef __G_PWOERKEY_H
#define __G_PWOERKEY_H

#ifdef __cplusplus
extern "C" {
#endif


/* Includes ------------------------------------------------------------------*/
#include "g_1903.h"
#include "g_vbat_ctr.h"

/** @defgroup PWR_KEY_TYPE Off Time Unit Block
 * @{
 */
#define PWK_OFF_TIME_4S      ((uint16_t)0x0000)
#define PWK_OFF_TIME_5S      ((uint16_t)0x0001)
#define PWK_OFF_TIME_6S      ((uint16_t)0x0002)
#define PWK_OFF_TIME_7S      ((uint16_t)0x0003)

#define IS_PWK_OFF_TIME(TIME)   (((TIME) == PWK_OFF_TIME_4S) || \
                                ((TIME) == PWK_OFF_TIME_5S) || \
                                ((TIME) == PWK_OFF_TIME_6S) || \
                                ((TIME) == PWK_OFF_TIME_7S))

/** @defgroup PWR_KEY_TYPE On Time Unit Block
 * @{
 */
#define PWK_ON_TIME_120MS       ((uint16_t)0x0000)
#define PWK_ON_TIME_400MS       ((uint16_t)0x0001)
#define PWK_ON_TIME_500MS       ((uint16_t)0x0002)
#define PWK_ON_TIME_1000MS      ((uint16_t)0x0003)

#define IS_PWK_ON_TIME(TIME)    (((TIME) == PWK_ON_TIME_120MS) || \
                                ((TIME) == PWK_ON_TIME_400MS) || \
                                ((TIME) == PWK_ON_TIME_500MS) || \
                                ((TIME) == PWK_ON_TIME_1000MS))


/** @defgroup interrupt type select
 * @{
 */
typedef enum {PWK_HIGH = 1, PWK_LOW = 0} PWK_TYPE;
#define IS_INT_SELECT(TYRE)    (((TYRE)  == 0) || ((TYRE)  == 1))

G_ErrorStatus PWK_Init(uint16_t off_time, uint16_t on_time, PWK_TYPE trigger_type);
void PWK_ITEnable(G_FunctionalState NewState);
void PWK_ClearITPendingBit(void);
void PWK_InterruptType(PWK_TYPE newtype);
G_FlagStatus PWK_GetPinState(void);

#ifdef __cplusplus
}
#endif

#endif

/************************ (C) COPYRIGHT GKT *****END OF FILE****/
